import { Service } from 'egg';

export default class CacheService extends Service {
    public async saveSmsCache(token: string, value: any) {
        await this.app.mysql.insert('sms_token', {
            ...value,
            token,
            created_at: this.app.mysql.literals.now,
        });
    }

    public async getSmsCache(token: string): Promise<any> {
        return await this.app.mysql.get('sms_token', { token });
    }

    public async delSmsCache(token: string) {
        await this.app.mysql.delete('sms_token', { token });
    }
}
